<?php
/*
	提现
 * [JINYUN!] (C)2001-2099 Jinyunweb.com
 * This is NOT a freeware, use is subject to license terms
 * $Id: 2017-12-13 03:39:35 apple $
*/
defined('BY_JYA') or exit('error');
global $_RQ;
$_RQ['op']=$_RQ['op']?$_RQ['op']:'get';
$return['ischecklogin']=cfc('core')->checklogin('','',true);
$credit_types=credit_types(true);
if($_RQ['op']=='get'){
	$member=$this->get('member',array('mid'=>$_SESSION['uid']));
	$basic=model('core/member')->basic($_SESSION['uid']);
	$member=array_merge($member,$basic);
	$return['member']=$member;
	$return['params']['type']=$_RQ['type']?:3;
	$return['allmoney']=$member['kuanb'];
	$return['typetitle']='车款标';
	$return['is_open']=$tixianset['is_open'];
	$return['open_upbaofee']=$tixianset['open_upbaofee'];
	$return['post']=array('type'=>$return['params']['type']);
	set_html('title','我的车款标');
	exi($return);
}
if($_RQ['op']=='list'){
	$pindex = max(1, intval($_RQ['page']));
	$psize = 15;
	$params=array('uniacid'=>$_SESSION['uniacid'],'mid'=>$_SESSION['uid']);
	if($_RQ['isadd']){
		$params['isadd']=intval($_RQ['isadd']);
	}
    $orderby='createtime desc';
	$total='';
	$list=pdo_getslice('jy_carfee_kuanblog',$params,array($pindex,$psize),$total,'','','id desc');
	if($list){
		foreach($list as &$item){
			$item['createtime']=date('Y/m/d H:i:s',$item['createtime']);
			$item['is_addtitle']=$item['isadd']?'获得':'消费';
			$item['typetitle']=$credit_types[$item['type']];
			$item['statustitle']=$this->kuanblog_status[$item['status']];
			if($item['kuanorderid']){
				$item['orderstatus']=$this->getcolumn('kuanorder',array('uniacid'=>$_SESSION['uniacid'],'id'=>$item['kuanorderid']),'status');
				$item['statustitle']=$this->kuanorder_status[$item['orderstatus']];
			}
		}
	}
	$return['list']=$list;
	exi($return);
}
if($_RQ['op']=='kuanorder'){
	$post=get_postdata();
	if(!$this->setting['gong_open']){
		exi('系统暂时不支持激活月供计划，不能申请！','error');
	}
	$member=$this->get('member',array('uniacid'=>$_SESSION['uniacid'],'mid'=>$_SESSION['uid']));
	if($member['kuanb']<1){
		exi('您的车款标不足1个，不能申请！','error');
	}
	$this->update('member',array('kuanb -='=>1),array('uniacid'=>$_SESSION['uniacid'],'mid'=>$_SESSION['uid']));
	$newpost=array(
		'mid'=>$_SESSION['uid'],
		'kuanorderid'=>$kuanorderid,
		'status'=>0,
		'fee'=>1,
	);
	$this->model('model')->addkuanblog($newpost,0,'激活年月供计划');
	exi('申请成功！等待审核');
}